package com.linux.huhx.thread;

import java.util.concurrent.TimeUnit;

public class HelloThread extends Thread {
    @Override
    public void run() {
        try {
            TimeUnit.SECONDS.sleep(1);
            System.out.println("Hello from a thread!");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        HelloThread helloThread = new HelloThread();
        helloThread.start();
        //
        TimeUnit.SECONDS.sleep(3);
        System.out.println(helloThread.getName());
        helloThread.start();
        System.out.println("In main thread.");
    }
}